package cn.yj.core.task.delay;

import java.util.concurrent.TimeUnit;

/**
 * @author 永健
 * @since 2021-05-12 13:50
 */
public abstract class BaseDelayTaskEntity {

    protected Runnable task;
    protected long delay;
    protected TimeUnit timeUnit;
    protected String unique;

    public BaseDelayTaskEntity(Runnable task, long delay, TimeUnit timeUnit,String unique) {
        this.task = task;
        this.delay = delay;
        this.timeUnit = timeUnit;
        this.unique = unique;
    }

    /**
     * 任务对象
     *
     * @return Runnable
     */
    public abstract Runnable getTask();

    /**
     * 任务执行时间
     *
     * @return long
     */
    public abstract long getDelay();

    /**
     * 任务执行时间单位
     *
     * @return TimeUnit
     */
    public abstract TimeUnit getTimeUnit();

    /**
     * 该标志用来判断延迟队列中是否已经存在
     * 当前任务的唯一标志
     * @return 唯一值
     */
    public abstract String getUnique();
}
